<?php
namespace app\minprogram\controller;
use app\minprogram\model\BatteryBanner;
use app\minprogram\model\Battery;
use think\Controller;
use think\Request;

use app\minprogram\model\LoginModel;
use app\minprogram\model\BatteryOrder;
//首页
class Index extends Common
{
    // banner
    public function getBannerList(){

        to_json_encode(200,'success',BatteryBanner::handleBannerList(BatteryBanner::getBannerList()));

    }

    // 商品列表
    
    public function getGoodsList(Request $request){

        $user_id = $this->checkLoginUser();
       // $user_id =74;
        $page = $request->param('page',1);
        to_json_encode(200,'success',Battery::handleGoodsList(Battery::getGoodsList(0,$page),$user_id));

    }
    
    public function gett()
    {
//        $openid='ouRPc4gvFXZtqqooknhyusWNgfbQ';
//        $info = LoginModel::getUserInfoByWxOpenid($openid);
//        var_dump($info);
//        dump(empty($info));
//        dump(isset($info['user_id']));
        $session_id='ouRPc4ovbUmmNH1lrSKeprswVuj8';
        $res = $this->checkLoginUser(true,$session_id);
       $user_id =$res;
        $type=0;
        $page=1;
        to_json_encode(200,'success',
            BatteryOrder::handleOrderList(
                BatteryOrder::getUserOrderList($user_id,$type,$page)
                ,$user_id)
        );
    }
}
